package com.kingmed.kmss.admin.modules.sys.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kingmed.kmss.admin.modules.sys.service.SysBpmnConfigService;
import com.kingmed.kmss.admin.modules.sys.vo.BpmnConfigDetailVO;
import com.kingmed.kmss.common.qc.admin.BpmnConfigQC;
import com.kingmed.kmss.common.vo.CommonResponse;
import com.kingmed.kmss.common.vo.CommonResponseHelper;
import com.kingmed.kmss.common.vo.admin.SysBpmnConfigVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 系统流程配置 前端控制器
 * </p>
 *
 * @author liangzhi
 * @since 2023-10-18
 */
@RestController
@RequestMapping("/sys/config/bpmn")
@Api(tags = "sys流程组配置")
public class SysBpmnConfigController {

    @Autowired
    private SysBpmnConfigService sysBpmnConfigService;


    @ApiOperation("获取子公司配置,不存在则取默认值")
    @GetMapping("/getByCompanyIdWithDefault")
    public CommonResponse<SysBpmnConfigVO> getByCompanyIdWithDefault(@RequestParam @ApiParam(value = "公司id",required = true) Long companyId) {
        return CommonResponseHelper.success(sysBpmnConfigService.getByCompanyIdWithDefault(companyId));
    }

    @ApiOperation("获取配置列表")
    @PostMapping("/pageListBpmnConfig")
    public CommonResponse<Page<SysBpmnConfigVO>> pageListBpmnConfig(@RequestBody BpmnConfigQC bpmnConfigQC) {
        Page<SysBpmnConfigVO> sysBpmnConfigVO = sysBpmnConfigService.pageList(bpmnConfigQC);
        return CommonResponseHelper.success(sysBpmnConfigVO);
    }


    @ApiOperation("获取配置详情")
    @GetMapping("/getConfigDetail")
    public CommonResponse<BpmnConfigDetailVO> getConfigDetail(@RequestParam @ApiParam(value = "配置主键",required = true) Long id) {
        return CommonResponseHelper.success(sysBpmnConfigService.getConfigDetail(id));
    }
}
